home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / C++ / Common / DXUTenum.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-09-27  |  7.6 KB  |  173 lines

  1. //--------------------------------------------------------------------------------------
  2. // File: DXUTEnum.h
  3. //
  4. // Enumerates D3D adapters, devices, modes, etc.
  5. //
  6. // Copyright (c) Microsoft Corporation. All rights reserved.
  7. //--------------------------------------------------------------------------------------
  8. #pragma once
  9. #ifndef DXUT_ENUM_H
  10. #define DXUT_ENUM_H
  11.  
  12. //--------------------------------------------------------------------------------------
  13. // Forward declarations
  14. //--------------------------------------------------------------------------------------
  15. class CD3DEnumAdapterInfo;
  16. class CD3DEnumDeviceInfo;
  17. struct CD3DEnumDeviceSettingsCombo;
  18. struct CD3DEnumDSMSConflict;
  19.  
  20.  
  21. //--------------------------------------------------------------------------------------
  22. // Enumerates available Direct3D adapters, devices, modes, etc.
  23. // Use DXUTGetEnumeration() to access global instance
  24. //--------------------------------------------------------------------------------------
  25. class CD3DEnumeration
  26. {
  27. public:
  28.     // These should be called before Enumerate(). 
  29.     //
  30.     // Use these calls and the IsDeviceAcceptable to control the contents of 
  31.     // the enumeration object, which affects the device selection and the device settings dialog.
  32.     void SetRequirePostPixelShaderBlending( bool bRequire ) { m_bRequirePostPixelShaderBlending = bRequire; }
  33.     void SetResolutionMinMax( UINT nMinWidth, UINT nMinHeight, UINT nMaxWidth, UINT nMaxHeight );  
  34.     void SetRefreshMinMax( UINT nMin, UINT nMax );
  35.     void SetMultisampleQualityMax( UINT nMax );    
  36.     void GetPossibleVertexProcessingList( bool* pbSoftwareVP, bool* pbHardwareVP, bool* pbPureHarewareVP, bool* pbMixedVP );
  37.     void SetPossibleVertexProcessingList( bool bSoftwareVP, bool bHardwareVP, bool bPureHarewareVP, bool bMixedVP );
  38.     CGrowableArray<D3DFORMAT>* GetPossibleDepthStencilFormatList();   
  39.     CGrowableArray<D3DMULTISAMPLE_TYPE>* GetPossibleMultisampleTypeList();   
  40.     CGrowableArray<UINT>* GetPossiblePresentIntervalList();
  41.     void ResetPossibleDepthStencilFormats();
  42.     void ResetPossibleMultisampleTypeList();
  43.     void ResetPossiblePresentIntervalList();
  44.  
  45.     // Call Enumerate() to enumerate available D3D adapters, devices, modes, etc.
  46.     HRESULT Enumerate( IDirect3D9* pD3D = NULL,
  47.                        LPDXUTCALLBACKISDEVICEACCEPTABLE IsDeviceAcceptableFunc = NULL );
  48.  
  49.     // These should be called after Enumerate() is called
  50.     CGrowableArray<CD3DEnumAdapterInfo*>*   GetAdapterInfoList();  
  51.     CD3DEnumAdapterInfo*                    GetAdapterInfo( UINT AdapterOrdinal );  
  52.     CD3DEnumDeviceInfo*                     GetDeviceInfo( UINT AdapterOrdinal, D3DDEVTYPE DeviceType );    
  53.     CD3DEnumDeviceSettingsCombo*            GetDeviceSettingsCombo( DXUTDeviceSettings* pDeviceSettings ) { return GetDeviceSettingsCombo( pDeviceSettings->AdapterOrdinal, pDeviceSettings->DeviceType, pDeviceSettings->AdapterFormat, pDeviceSettings->pp.BackBufferFormat, pDeviceSettings->pp.Windowed ); }
  54.     CD3DEnumDeviceSettingsCombo*            GetDeviceSettingsCombo( UINT AdapterOrdinal, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL Windowed );  
  55.  
  56.     ~CD3DEnumeration();
  57.  
  58. private:
  59.     friend CD3DEnumeration* DXUTGetEnumeration(); 
  60.  
  61.     // Use DXUTGetEnumeration() to access global instance
  62.     CD3DEnumeration();
  63.  
  64.     IDirect3D9* m_pD3D;                                    
  65.     LPDXUTCALLBACKISDEVICEACCEPTABLE m_IsDeviceAcceptableFunc;
  66.     bool m_bRequirePostPixelShaderBlending;
  67.     CGrowableArray<D3DFORMAT> m_DepthStecilPossibleList;
  68.     CGrowableArray<D3DMULTISAMPLE_TYPE> m_MultiSampleTypeList;
  69.     CGrowableArray<UINT> m_PresentIntervalList;
  70.  
  71.     bool m_bSoftwareVP;
  72.     bool m_bHardwareVP;
  73.     bool m_bPureHarewareVP;
  74.     bool m_bMixedVP;
  75.  
  76.     UINT m_nMinWidth;
  77.     UINT m_nMaxWidth;
  78.     UINT m_nMinHeight;
  79.     UINT m_nMaxHeight;
  80.     UINT m_nRefreshMin;
  81.     UINT m_nRefreshMax;
  82.     UINT m_nMultisampleQualityMax;
  83.  
  84.     // Array of CD3DEnumAdapterInfo* with unique AdapterOrdinals
  85.     CGrowableArray<CD3DEnumAdapterInfo*> m_AdapterInfoList;  
  86.  
  87.     HRESULT EnumerateDevices( CD3DEnumAdapterInfo* pAdapterInfo, CGrowableArray<D3DFORMAT>* pAdapterFormatList );
  88.     HRESULT EnumerateDeviceCombos( CD3DEnumAdapterInfo* pAdapterInfo, CD3DEnumDeviceInfo* pDeviceInfo, CGrowableArray<D3DFORMAT>* pAdapterFormatList );
  89.     void BuildDepthStencilFormatList( CD3DEnumDeviceSettingsCombo* pDeviceCombo );
  90.     void BuildMultiSampleTypeList( CD3DEnumDeviceSettingsCombo* pDeviceCombo );
  91.     void BuildDSMSConflictList( CD3DEnumDeviceSettingsCombo* pDeviceCombo );
  92.     void BuildVertexProcessingTypeList( CD3DEnumDeviceInfo* pDeviceInfo, CD3DEnumDeviceSettingsCombo* pDeviceCombo );
  93.     void BuildPresentIntervalList( CD3DEnumDeviceInfo* pDeviceInfo, CD3DEnumDeviceSettingsCombo* pDeviceCombo );
  94.     void ClearAdapterInfoList();
  95. };
  96.  
  97. CD3DEnumeration* DXUTGetEnumeration(); 
  98.  
  99.  
  100. //--------------------------------------------------------------------------------------
  101. // A class describing an adapter which contains a unique adapter ordinal 
  102. // that is installed on the system
  103. //--------------------------------------------------------------------------------------
  104. class CD3DEnumAdapterInfo
  105. {
  106. public:
  107.     ~CD3DEnumAdapterInfo();
  108.  
  109.     UINT AdapterOrdinal;
  110.     D3DADAPTER_IDENTIFIER9 AdapterIdentifier;
  111.     WCHAR szUniqueDescription[256];
  112.  
  113.     CGrowableArray<D3DDISPLAYMODE> displayModeList; // Array of supported D3DDISPLAYMODEs
  114.     CGrowableArray<CD3DEnumDeviceInfo*> deviceInfoList; // Array of CD3DEnumDeviceInfo* with unique supported DeviceTypes
  115. };
  116.  
  117.  
  118. //--------------------------------------------------------------------------------------
  119. // A class describing a Direct3D device that contains a 
  120. //       unique supported device type 
  121. //--------------------------------------------------------------------------------------
  122. class CD3DEnumDeviceInfo
  123. {
  124. public:
  125.     ~CD3DEnumDeviceInfo();
  126.  
  127.     UINT AdapterOrdinal;
  128.     D3DDEVTYPE DeviceType;
  129.     D3DCAPS9 Caps;
  130.  
  131.     // List of CD3DEnumDeviceSettingsCombo* with a unique set 
  132.     // of AdapterFormat, BackBufferFormat, and Windowed
  133.     CGrowableArray<CD3DEnumDeviceSettingsCombo*> deviceSettingsComboList; 
  134. };
  135.  
  136.  
  137. //--------------------------------------------------------------------------------------
  138. // A struct describing device settings that contains a unique combination of 
  139. // adapter format, back buffer format, and windowed that is compatible with a 
  140. // particular Direct3D device and the app.
  141. //--------------------------------------------------------------------------------------
  142. struct CD3DEnumDeviceSettingsCombo
  143. {
  144.     UINT AdapterOrdinal;
  145.     D3DDEVTYPE DeviceType;
  146.     D3DFORMAT AdapterFormat;
  147.     D3DFORMAT BackBufferFormat;
  148.     BOOL Windowed;
  149.  
  150.     CGrowableArray<D3DFORMAT> depthStencilFormatList; // List of D3DFORMATs
  151.     CGrowableArray<D3DMULTISAMPLE_TYPE> multiSampleTypeList; // List of D3DMULTISAMPLE_TYPEs
  152.     CGrowableArray<DWORD> multiSampleQualityList; // List of number of quality levels for each multisample type
  153.     CGrowableArray<UINT> presentIntervalList; // List of D3DPRESENT flags
  154.     CGrowableArray<CD3DEnumDSMSConflict> DSMSConflictList; // List of CD3DEnumDSMSConflict
  155.  
  156.     CD3DEnumAdapterInfo* pAdapterInfo;
  157.     CD3DEnumDeviceInfo* pDeviceInfo;
  158. };
  159.  
  160.  
  161. //--------------------------------------------------------------------------------------
  162. // A depth/stencil buffer format that is incompatible with a
  163. // multisample type.
  164. //--------------------------------------------------------------------------------------
  165. struct CD3DEnumDSMSConflict
  166. {
  167.     D3DFORMAT DSFormat;
  168.     D3DMULTISAMPLE_TYPE MSType;
  169. };
  170.  
  171.  
  172. #endif
  173.